Skip to content

Comments

Fixes #134: add xr.Dataset as input type for appropriate modules#854

Merged
brendancol merged 2 commits intomasterfrom
fixes-134-add-xr.dataset-as-input-type-for-appropriate-modules
Feb 20, 2026
Merged

Fixes #134: add xr.Dataset as input type for appropriate modules#854
brendancol merged 2 commits intomasterfrom
fixes-134-add-xr.dataset-as-input-type-for-appropriate-modules

Conversation

@brendancol
Copy link
Contributor

@brendancol brendancol commented Feb 20, 2026

Summary

  • Adds transparent xr.Dataset support to ~25 public functions via two new decorators in xrspatial/dataset_support.py:
    • @supports_dataset (single-input functions): iterates over data_vars, calls the original function on each, returns a new Dataset. Applied to slope, aspect, curvature, hillshade, focal.mean, 10 classify functions, and 3 proximity functions.
    • @supports_dataset_bands (multi-input functions): accepts a Dataset with band-name keyword arguments (e.g. ndvi(ds, nir='B8', red='B4')). Applied to 10 multispectral index functions.
  • Adds inline Dataset handling to zonal.stats: runs per-variable, prefixes stat columns with the variable name, and merges into a single DataFrame.
  • Existing xr.DataArray call paths are completely unchanged (passthrough).
  • Updates all documentation:
    • Docstrings for all 28 decorated functions (parameter types + return types)
    • README, CHANGELOG, usage.rst, data_types.rst
    • Surface and multispectral notebooks (both docs/ and examples/ versions)

Test plan

  • 18 new tests in test_dataset_support.py covering all three patterns (single-input, multi-input, zonal stats), including error cases
  • Full existing test suite passes (596 passed, 12 skipped, 0 failed)

Closes #134

Add transparent Dataset support via two decorators in a new
dataset_support module. Single-input functions (slope, aspect,
curvature, hillshade, focal.mean, 10 classify functions, 3 proximity
functions) iterate over data_vars and return a Dataset. Multi-input
functions (10 multispectral indices) accept a Dataset with band-name
kwargs. zonal.stats merges per-variable DataFrames with prefixed
columns. Includes 18 new tests.
Update docstrings, prose docs, notebooks, README, and changelog to
reflect that most public functions now accept xr.Dataset in addition
to xr.DataArray.
@brendancol brendancol merged commit e1370ef into master Feb 20, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add xr.Dataset as input type for appropriate modules

1 participant